<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	template="../template/template.xhtml">
	<ui:define name="content">
		<h:form id="form">
			<p:dataTable value="#{carrinhoBean.listaItemPedido}" var="i" paginator="true"
				rows="10" id="listaItens"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15" binding="#{carrinhoBean.datatable}">
				<f:facet name="header">
					<h:outputText value="Lista de Itens" />
				</f:facet>

				<p:column>
					<f:facet name="header">
						<h:outputText value="Cidade/Aeroporto de Origem" />
					</f:facet>
					<h:outputText value="#{i.voo.cidadeOrigem.nomeCidade}" />/<br />
					<h:outputText value="#{i.voo.aeroportoOrigem.nomeAeroporto}" />
				</p:column>

				<p:column>
					<f:facet name="header">
						<h:outputText value="Quantidade" />
					</f:facet>
					<p:spinner value="#{i.quantidade}" min="0" >
						<p:ajax event="change" process="@this" listener="#{carrinhoBean.calcularTotal}" update="total" />
					</p:spinner>
				</p:column>
				
				<p:column>
					<f:facet name="header">
						<h:outputText value="Preço Unit." />
					</f:facet>
					<h:outputText value="#{i.voo.preco}" />
				</p:column>
				
				<p:column>
					<f:facet name="header">
						<h:outputText value="SubTotal" />
					</f:facet>
					<h:outputText value="#{i.subTotalProduto}" />
				</p:column>

			</p:dataTable>
			<h:outputText id="total" value="#{carrinhoBean.total}" style="float:right;"/>
			<p:commandButton id="buttonFinalizarCompra" value="Finalizar Compra"
				action="#{carrinhoBean.finalizarCompra}" process="@form" update="@form" />
		</h:form>
	</ui:define>
</ui:composition>
